<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('产品列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>产品名称：</p>
                            <input type="text" name="pname"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:product:add">
                <i class="fa fa-plus"></i> 添加
            </a>

            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:product:remove">
                <i class="fa fa-remove"></i> 删除
            </a>

        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:product:edit')}]];
    var listFlag = [[${@permission.hasPermi('system:product:list')}]];
    var removeFlag = [[${@permission.hasPermi('system:product:remove')}]];
    var prefix = ctx + "system/product";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",

            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "产品信息",
            columns: [{
                checkbox: true
            },
                {
                    field : 'pid',
                    title : '型号',

                },
                {
                    field : 'pname',
                    title : '产品名称'
                },
                {
                    field : 'url',
                    title : '图片',
                    formatter: function (value, row, index) {
                        return '<img src="' + value + '" width="80" height="60">';
                    }

                },
                {
                    field : 'sname',
                    title : '系列'
                },
                {
                    field : 'style',
                    title : '风格'
                },
                {
                    field : 'specification',
                    title : '规格'
                },
                {
                    field : 'texture',
                    title : '材质'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];

                        actions.push('<a class="btn btn-info btn-xs ' + listFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.pid + '\')"><i class="fa fa-list-ul"></i>查看</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    /*字典列表-详细*/
    function detail(pid) {
        var url = prefix + '/show/' + pid;
        $.modal.openTab("商品详情", url);
    }
</script>
</body>
</html>